#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=100000;

int max(int a, int b) {
  return a>b ? a : b;
}

int main() {
  freopen("sequence.in", "r", stdin);
  freopen("sequence.out", "w", stdout);

  static int que[maxn+1];
  int n;
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    scanf("%d", que+i);
  }

  static int quemin[maxn+1][2], quemax[maxn+1][2];
  int m;
  scanf("%d", &m);
  for (int mi=1; mi<=m; mi++) {
    int l, r;
    scanf("%d %d", &l, &r);
    int minh=l, mint=l-1, maxh=l, maxt=l-1, ansl=1, ansr=n;
    for (int i=l; i<=n; i++) {
      if (minh>mint || quemin[mint][1]>que[i]) {
	quemin[++mint][1] = que[i];
	quemin[mint][0] = i;
      }
      if (maxh>maxt || quemax[maxt][1]<que[i]) {
	quemax[++maxt][1] = que[i];
	quemax[maxt][0] = i;
      }
    }
    for (int i=l; i>0; i--) {
      for (; minh<=mint && quemin[minh][1]>=que[i]; minh++);
      quemin[--minh][1] = que[i];
      quemin[minh][0] = i;
      for (; maxh<=maxt && quemax[maxh][1]<=que[i]; maxh++);
      quemax[--maxh][1] = que[i];
      quemax[maxh][0] = i;
      
      for (int p=minh, q=maxh; p<=mint && q<=maxt; ) {
	int next, now=max(quemin[p][0], quemax[q][0]), temp=quemax[q][1]-quemin[p][1]+1;
	if (p>=mint && q>=maxt) {
	  next = n+1;
	} else if (p<mint && (q>=maxt || quemin[p+1][0]<=quemax[q+1][0])) {
	  next = quemin[p+1][0];
	} else {
	  next = quemax[q+1][0];
	}
	if (temp>=now-i+1 && temp<=next-i && i+temp-1>=r) {
	  if (temp<=ansr-ansl+1) {
	    ansr = i+temp-1;
	    ansl = i;
	  }
	  break;
	}
	if (p<mint && (q>=maxt || quemin[p+1][0]<=quemax[q+1][0])) {
	  p++;
	} else {
	  q++;
	}
      }
    }
    printf("%d %d\n", ansl, ansr);
  }

  fclose(stdin);
  fclose(stdout);
}
